﻿using Avalonia.Data.Converters;
using System;
using System.Globalization;

namespace LayoutViewer.Converters
{
    class ScaleFactorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var scaleFactor = (double)value;
            return scaleFactor switch
            {
                0.2 => 0,
                0.4 => 1,
                0.6 => 2,
                0.8 => 3,
                1.0 => 4,
                1.2 => 5,
                1.5 => 6,
                _ => 4
            };
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var scaleFactor = (int)value;
            return scaleFactor switch
            {
                0 => 0.2,
                1 => 0.4,
                2 => 0.6,
                3 => 0.8,
                4 => 1.0,
                5 => 1.2,
                6 => 1.5,
                _ => 1.0
            };
        }
    }
}
